package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.example.demo.entity.User;
import com.example.demo.service.UserIndexService;

@Controller
@RequestMapping("/UserIndex")
public class UserIndexController {

	@Autowired
	private UserIndexService userIndexService;
	
	
	@RequestMapping("/yanzheng")
	public ModelAndView UserIndex(@RequestParam("username") String username, 
							@RequestParam("password") String password) {
		ModelAndView model = new ModelAndView();
		
		
		User user=new User();
		user.setusername(username);
		user.setpassword(password);
		
		if(userIndexService.Index(username,password))
		{

			model.setViewName("/CompDcMain.html");
			return model;
		}
		else {
			model.setViewName("/index.html");
			model.addObject("msg", "用户名或密码错误");
			return model;
	}
	}
}
	
